// run: $exec < input
// std: c++03
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>

template <class T>
struct point
{
	typedef T value_type;
	point(value_type x, value_type y) : x(x), y(y) {};
	point() {};
	value_type x, y;
	double polar_angle;
	long long index;
};

template <class T>
bool operator<(point<T> const & a, point<T> const & b)
{
	return (a.y < b.y || (a.y == b.y && a.x < b.x));
}

template <class T>
std::istream & operator>>(std::istream & is, point<T> & a)
{
	is >> a.x >> a.y;
	return is;
}

std::vector<point<long long> > points;

template <class T>
T abs(T a) { return (a > 0) ? a : -a; }

template <class T>
T ccw(point<T> const & a, point<T> const & b, point<T> const & c)
{
	return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}

template <class T>
bool closer(point<T> const & a, point<T> const & b, point<T> const & c)
{
	return abs(b.x - a.x) + abs(b.y - a.y) < abs(c.x - a.x) + abs(c.y - a.y);
}

template <class T>
struct cmp
{
	bool operator()(point<T> const & a, point<T> const & b)
	{
		int c = ccw(points[1], a, b);
		return c > 0 || (c == 0 && closer(points[1], a, b));
	}
};

int main()
{
	std::ios::sync_with_stdio(false);

	/*
	points.resize(3);
	point<long long> aa(0, 0);
	point<long long> bb(1, 0);
	point<long long> cc(2, 0);
	points[1] = aa;
	std::cout << cmp<long long>()(bb, cc) << '\n';
	std::cout << ccw<long long>(aa, bb, cc) << '\n';
	std::cout << closer<long long>(aa, bb, cc) << '\n';
	return 0;
	*/

	long long n; std::cin >> n;
	points.resize(n+1);
	for (int i = 1; i <= n; i++) {
		std::cin >> points[i];
		points[i].index = i;
		if (points[i] < points[1]) std::swap(points[i], points[1]);
	}
	/*
	for (int i = 2; i <= n; i++) {
		int x = points[i].x - points[1].x;
		int y = points[i].y - points[1].y;
		points[i].polar_angle = std::atan(double(y)/double(x));
		if (points[i].polar_angle < 0) points[i].polar_angle += M_PI;
	}
	*/

	std::sort(points.begin()+2, points.end(), cmp<long long>());
	std::cout << "pre sort: \n";
	for (int i = 1; i <= n; i++) std::cout << points[i].index << '\n';
	std::cout << "end sort\n";
	points[0] = points[n];

	long long c = 1; //convex points counter
	for (int i = 2; i <= n; i++) {
		for (; i <= n && ccw(points[c-1], points[c], points[i]) < 0; )
			(c > 1) ? c-- : i++;
		std::swap(points[++c], points[i]);
	}

	// the perimeter of the convex hull
	long long ans = 1;
	for (int i = 1; i <= c; i++) {
		ans = (ans * points[i].index) % (n + 1);
		std::cout << "--->" << points[i].index << '\n';
	}
	ans = (ans * c) % (n + 1);
	std::cout << ans << '\n';
}

